//
//  TicketViewController.m
//  BigJoy
//
//  Created by Rowling on 2017/6/27.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "TicketViewController.h"
#import "TicketCell.h"
@interface TicketViewController ()
@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (weak, nonatomic) IBOutlet UIButton *weishiyongButton;
@property (weak, nonatomic) IBOutlet UIButton *shiyongjiluButton;
@property (weak, nonatomic) IBOutlet UIButton *guoqiButton;
@property (nonatomic,strong) NSArray *buttonArray;
@property (nonatomic,assign) UseType type;
@end

@implementation TicketViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.buttonArray = @[self.weishiyongButton,self.shiyongjiluButton,self.guoqiButton];
    [self setUI];
}
- (IBAction)indexButtonClick:(UIButton *)sender {
    for (UIButton * btn in self.buttonArray) {
        btn.selected = NO;
    }
    sender.selected = YES;
    NSInteger tag = sender.tag - 100;
    if (tag == 0) {
        //未使用
        self.type = UseAble;
    }
    if (tag == 1) {
        //使用记录
        self.type = hadUse;
    }
    if (tag == 2) {
        //已过期
        self.type = OutDate;
    }
    [self.XMTableview reloadData];
}

-(void)setUI {
    self.XMTableview.backgroundColor = [UIColor whiteColor];
    self.title = @"优惠券";
    [self.view addSubview:self.XMTableview];
    [self.XMTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self.contentView);
    }];
    self.hideNavLine = YES;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TicketCell * cell = [TicketCell cellWithTalbelView:tableView];
    cell.type = self.type;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}

@end
